//<MStar Software>
//******************************************************************************
// MStar Software
// Copyright (c) 2010 - 2014 MStar Semiconductor, Inc. All rights reserved.
// All software, firmware and related documentation herein ("MStar Software") are
// intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
// law, including, but not limited to, copyright law and international treaties.
// Any use, modification, reproduction, retransmission, or republication of all
// or part of MStar Software is expressly prohibited, unless prior written
// permission has been granted by MStar.
//
// By accessing, browsing and/or using MStar Software, you acknowledge that you
// have read, understood, and agree, to be bound by below terms ("Terms") and to
// comply with all applicable laws and regulations:
//
// 1. MStar shall retain any and all right, ownership and interest to MStar
//    Software and any modification/derivatives thereof.
//    No right, ownership, or interest to MStar Software and any
//    modification/derivatives thereof is transferred to you under Terms.
//
// 2. You understand that MStar Software might include, incorporate or be
//    supplied together with third party's software and the use of MStar
//    Software may require additional licenses from third parties.
//    Therefore, you hereby agree it is your sole responsibility to separately
//    obtain any and all third party right and license necessary for your use of
//    such third party's software.
//
// 3. MStar Software and any modification/derivatives thereof shall be deemed as
//    MStar's confidential information and you agree to keep MStar's
//    confidential information in strictest confidence and not disclose to any
//    third party.
//
// 4. MStar Software is provided on an "AS IS" basis without warranties of any
//    kind. Any warranties are hereby expressly disclaimed by MStar, including
//    without limitation, any warranties of merchantability, non-infringement of
//    intellectual property rights, fitness for a particular purpose, error free
//    and in conformity with any international standard.  You agree to waive any
//    claim against MStar for any loss, damage, cost or expense that you may
//    incur related to your use of MStar Software.
//    In no event shall MStar be liable for any direct, indirect, incidental or
//    consequential damages, including without limitation, lost of profit or
//    revenues, lost or damage of data, and unauthorized system use.
//    You agree that this Section 4 shall still apply without being affected
//    even if MStar Software has been modified by MStar in accordance with your
//    request or instruction for your use, except otherwise agreed by both
//    parties in writing.
//
// 5. If requested, MStar may from time to time provide technical supports or
//    services in relation with MStar Software to you for your use of
//    MStar Software in conjunction with your or your customer's product
//    ("Services").
//    You understand and agree that, except otherwise agreed by both parties in
//    writing, Services are provided on an "AS IS" basis and the warranty
//    disclaimer set forth in Section 4 above shall apply.
//
// 6. Nothing contained herein shall be construed as by implication, estoppels
//    or otherwise:
//    (a) conferring any license or right to use MStar name, trademark, service
//        mark, symbol or any other identification;
//    (b) obligating MStar or any of its affiliates to furnish any person,
//        including without limitation, you and your customers, any assistance
//        of any kind whatsoever, or any information; or
//    (c) conferring any license or right under any intellectual property right.
//
// 7. These terms shall be governed by and construed in accordance with the laws
//    of Taiwan, R.O.C., excluding its conflict of law rules.
//    Any and all dispute arising out hereof or related hereto shall be finally
//    settled by arbitration referred to the Chinese Arbitration Association,
//    Taipei in accordance with the ROC Arbitration Law and the Arbitration
//    Rules of the Association by three (3) arbitrators appointed in accordance
//    with the said Rules.
//    The place of arbitration shall be in Taipei, Taiwan and the language shall
//    be English.
//    The arbitration award shall be final and binding to both parties.
//
//******************************************************************************
//<MStar Software>

package com.android.tv.settings.update;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.RadioGroup;  
import android.widget.RadioButton;  
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Toast; 
import android.os.SystemProperties;

import com.android.tv.settings.R;
import com.android.tv.settings.util.Tools;


public class DlpAdjActivity extends com.android.BaseActivity {

    private final static String TAG = "DlpAdjActivity";

    private Button btnWrite;
	private Button btnReset;
	private Button btnResetGen;
	
	private TextView mTextViewR;
	private TextView mTextViewG;
	private TextView mTextViewB;
	private SeekBar mSeekBarR;
	private SeekBar mSeekBarG;
	private SeekBar mSeekBarB;
	private RadioGroup mRadioGroup;
	RadioButton mRadioButtonHot;
	RadioButton mRadioButtonMid;
	RadioButton mRadioButtonCold;
	
	private int mPwmR;
	private int mPwmG;
	private int mPwmB;
	private int mPwmR1;
	private int mPwmG1;
	private int mPwmB1;
	private int mPwmR2;
	private int mPwmG2;
	private int mPwmB2;
	private int mBright;
	private int mTempColor;

	private boolean isWriteSave;
	private boolean isUpdate;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dlp_adj);
        findViews();
    	isWriteSave = false;
		isUpdate = false;
    }

    @Override
    protected void onDestroy() {
        if (isWriteSave == false)
        {
			restorePwm( );
		}
		else
		{
			resetTempColor( mTempColor , 1);
		}
        super.onDestroy();
    }
	
	@Override  
	protected void onPause() {  
		super.onPause();  
	  	 finish();
	}  
	
	private void restorePwm( )
	{
		String mtmp = SystemProperties.get("persist.dlp.pwmr", "0");
		isUpdate = false;
		if (mPwmR != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmr", Integer.toString(mPwmR));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmg", "0");
		if (mPwmG != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmg", Integer.toString(mPwmG));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmb", "0");
		if (mPwmB != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmb", Integer.toString(mPwmB));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmr1", "0");
		if (mPwmR1 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmr1", Integer.toString(mPwmR1));
			isUpdate = true;
		}		
		
		mtmp = SystemProperties.get("persist.dlp.pwmg1", "0");
		if (mPwmG1 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmg1", Integer.toString(mPwmG1));
			isUpdate = true;
		}		
		
		mtmp = SystemProperties.get("persist.dlp.pwmb1", "0");
		if (mPwmB1 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmb1", Integer.toString(mPwmB1));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmr2", "0");
		if (mPwmR2 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmr2", Integer.toString(mPwmR2));
			isUpdate = true;
		}			
		
		mtmp = SystemProperties.get("persist.dlp.pwmg2", "0");
		if (mPwmG2 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmg2", Integer.toString(mPwmG2));
			isUpdate = true;
		}		
		
		mtmp = SystemProperties.get("persist.dlp.pwmb2", "0");
		if (mPwmB2 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmb2", Integer.toString(mPwmB2));
			isUpdate = true;
		}	
		/*
		mtmp = SystemProperties.get("persist.dlp.brightness", "0");
		if(	mBright != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.brightness", Integer.toString(mBright));
			isUpdate = true;
		}

		mtmp = SystemProperties.get("persist.dlp.temp", "0");
		if(	mTempColor != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.temp", Integer.toString(mTempColor));
			isUpdate = true;
		}
		*/
					
		if (isUpdate)
		{
			SystemProperties.set("persist.dlp.update", "10");
		}
	}

	private void restoreGenPwm( )
	{
		String mtmp = SystemProperties.get("persist.dlp.pwmr", "0");
		isUpdate = false;
		if (203 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmr", Integer.toString(203));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmg", "0");
		if (220 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmg", Integer.toString(220));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmb", "0");
		if (235 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmb", Integer.toString(235));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmr1", "0");
		if (203 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmr1", Integer.toString(203));
			isUpdate = true;
		}		
		
		mtmp = SystemProperties.get("persist.dlp.pwmg1", "0");
		if (220 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmg1", Integer.toString(220));
			isUpdate = true;
		}		
		
		mtmp = SystemProperties.get("persist.dlp.pwmb1", "0");
		if (235 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmb1", Integer.toString(235));
			isUpdate = true;
		}
		
		mtmp = SystemProperties.get("persist.dlp.pwmr2", "0");
		if (203 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmr2", Integer.toString(203));
			isUpdate = true;
			mTextViewR.setText(Integer.toString(203));
			mSeekBarR.setProgress(203);
		}			
		
		mtmp = SystemProperties.get("persist.dlp.pwmg2", "0");
		if (220 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmg2", Integer.toString(220));
			isUpdate = true;
			mTextViewG.setText(Integer.toString(220));
			mSeekBarG.setProgress(220);
		}		
		
		mtmp = SystemProperties.get("persist.dlp.pwmb2", "0");
		if (235 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.pwmb2", Integer.toString(235));
			isUpdate = true;
			mTextViewB.setText(Integer.toString(235));
			mSeekBarB.setProgress(235);
		}	
		
		mtmp = SystemProperties.get("persist.dlp.brightness", "0");
		if( 10 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.brightness", Integer.toString(10));
			isUpdate = true;
		}
	
		mtmp = SystemProperties.get("persist.dlp.temp", "0");
		if( 2 != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.temp", Integer.toString(2));
			isUpdate = true;
			mRadioGroup.clearCheck();
			mRadioButtonCold.setChecked(true);
		}
					
		if (isUpdate)
		{
			SystemProperties.set("persist.dlp.update", "10");
			isWriteSave = true;
		}
		//mTextViewR.setText(mtmp);
		//mSeekBarR.setProgress(Integer.valueOf(mtmp));
	}


	private void resetTempColor( int oriColor,int updatebright)
	{
		String mtmp = SystemProperties.get("persist.dlp.temp", "0");
		if(	oriColor != Integer.valueOf(mtmp))
		{
			SystemProperties.set("persist.dlp.temp", Integer.toString(oriColor));
			if (updatebright != 0)
			{
				mtmp = SystemProperties.get("persist.dlp.brightness", "0");
				if( mBright != Integer.valueOf(mtmp))
				{
					SystemProperties.set("persist.dlp.brightness",Integer.toString(mBright));
				}
				SystemProperties.set("persist.dlp.update", "10");//change all
			}
			else
			{
				SystemProperties.set("persist.dlp.update", "1"); //change tempcolor
			}
		}
		else
		{
			if (updatebright != 0)
			{
				mtmp = SystemProperties.get("persist.dlp.brightness", "0");
				if( mBright != Integer.valueOf(mtmp))
				{
					SystemProperties.set("persist.dlp.brightness",Integer.toString(mBright));
					SystemProperties.set("persist.dlp.update", "10");
				}
			}
		}
	}

	private void refreshViews( )
	{	
		String tmpStr = null;
		mRadioGroup.clearCheck();
		if (mTempColor == 0)
		{
			mRadioButtonHot.setChecked(true);
			tmpStr = SystemProperties.get("persist.dlp.pwmr");
			mTextViewR.setText(tmpStr);
			mSeekBarR.setProgress(Integer.valueOf(tmpStr));
			tmpStr = SystemProperties.get("persist.dlp.pwmg");
			mTextViewG.setText(tmpStr);
			mSeekBarG.setProgress(Integer.valueOf(tmpStr));
			tmpStr = SystemProperties.get("persist.dlp.pwmb");
			mTextViewB.setText(tmpStr);
			mSeekBarB.setProgress(Integer.valueOf(tmpStr));
		}
		else if (mTempColor == 1)
		{
			mRadioButtonMid.setChecked(true);
			tmpStr = SystemProperties.get("persist.dlp.pwmr1");
			mTextViewR.setText(tmpStr);
			mSeekBarR.setProgress(Integer.valueOf(tmpStr));
			tmpStr = SystemProperties.get("persist.dlp.pwmg1");
			mTextViewG.setText(tmpStr);
			mSeekBarG.setProgress(Integer.valueOf(tmpStr));
			tmpStr = SystemProperties.get("persist.dlp.pwmb1");
			mTextViewB.setText(tmpStr);
			mSeekBarB.setProgress(Integer.valueOf(tmpStr));
		}
		else if (mTempColor == 2)
		{
			mRadioButtonCold.setChecked(true);
			tmpStr = SystemProperties.get("persist.dlp.pwmr2");
			mTextViewR.setText(tmpStr);
			mSeekBarR.setProgress(Integer.valueOf(tmpStr));
			tmpStr = SystemProperties.get("persist.dlp.pwmg2");
			mTextViewG.setText(tmpStr);
			mSeekBarG.setProgress(Integer.valueOf(tmpStr));
			tmpStr = SystemProperties.get("persist.dlp.pwmb2");
			mTextViewB.setText(tmpStr);
			mSeekBarB.setProgress(Integer.valueOf(tmpStr));
		}
	}
	
    private void findViews() {
		mRadioGroup = (RadioGroup) findViewById(R.id.temp);
		mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
					@Override
					public void onCheckedChanged(RadioGroup group,int checkedId) {
						switch (checkedId){
							case R.id.hotcolor:
								//Toast.makeText(getApplicationContext(), "Hot", Toast.LENGTH_LONG).show();
								mTextViewR.setText("R:" + SystemProperties.get("persist.dlp.pwmr", "0"));
								mTextViewG.setText("G:" + SystemProperties.get("persist.dlp.pwmg", "0"));
								mTextViewB.setText("B:" + SystemProperties.get("persist.dlp.pwmb", "0"));
								resetTempColor( 0 , 0);
								break;
							case R.id.midcolor:
								//Toast.makeText(getApplicationContext(), "Mid", Toast.LENGTH_LONG).show();  	
								mTextViewR.setText("R:" + SystemProperties.get("persist.dlp.pwmr1", "0"));
								mTextViewG.setText("G:" + SystemProperties.get("persist.dlp.pwmg1", "0"));
								mTextViewB.setText("B:" + SystemProperties.get("persist.dlp.pwmb1", "0"));
								resetTempColor( 1 , 0 );
								break;
							case R.id.coldcolor:
								//Toast.makeText(getApplicationContext(), "Cold", Toast.LENGTH_LONG).show();  		
								mTextViewR.setText("R:" + SystemProperties.get("persist.dlp.pwmr2", "0"));
								mTextViewG.setText("G:" + SystemProperties.get("persist.dlp.pwmg2", "0"));
								mTextViewB.setText("B:" + SystemProperties.get("persist.dlp.pwmb2", "0"));
								resetTempColor( 2 , 0 );
								break;
						}
						
					}
				});
				
				mTextViewR = (TextView) findViewById(R.id.textR);
				mTextViewG = (TextView) findViewById(R.id.textG);
				mTextViewB = (TextView) findViewById(R.id.textB);
				mSeekBarR  = (SeekBar) findViewById(R.id.seekBarR);
				mSeekBarG  = (SeekBar) findViewById(R.id.seekBarG);
				mSeekBarB  = (SeekBar) findViewById(R.id.seekBarB);
			    mRadioButtonHot = (RadioButton) findViewById(R.id.hotcolor);
				mRadioButtonMid = (RadioButton) findViewById(R.id.midcolor);
				mRadioButtonCold = (RadioButton) findViewById(R.id.coldcolor);
				
			mSeekBarR.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
				@Override
				public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
					if (progress < 125)
					{
						mSeekBarR.setProgress(125);
					}
					else
					{
						mTextViewR.setText("R:" + Integer.toString(progress));
						if (mRadioButtonHot.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmr", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
						else if (mRadioButtonMid.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmr1", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
						else if (mRadioButtonCold.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmr2", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
					}
				}
				@Override
	            public void onStartTrackingTouch(SeekBar seekBar) {
	            }

	            @Override
	            public void onStopTrackingTouch(SeekBar seekBar) {
	            }
			});
			mSeekBarG.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
				@Override
				public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
					if (progress < 125)
					{
						mSeekBarG.setProgress(125);
					}
					else
					{
						mTextViewG.setText("G:" + Integer.toString(progress));
						if (mRadioButtonHot.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmg", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
						else if (mRadioButtonMid.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmg1", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
						else if (mRadioButtonCold.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmg2", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
					}
				}
				@Override
	            public void onStartTrackingTouch(SeekBar seekBar) {
	            }

	            @Override
	            public void onStopTrackingTouch(SeekBar seekBar) {
	            }
			});			
			mSeekBarB.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
				@Override
				public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
					if (progress < 125)
					{
						mSeekBarB.setProgress(125);
					}
					else
					{
						mTextViewB.setText("B:" + Integer.toString(progress));
						if (mRadioButtonHot.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmb", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
						else if (mRadioButtonMid.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmb1", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
						else if (mRadioButtonCold.isChecked())
						{
							SystemProperties.set("persist.dlp.pwmb2", Integer.toString(progress));
							SystemProperties.set("persist.dlp.update", "5");
						}
					}
				}
				@Override
		        public void onStartTrackingTouch(SeekBar seekBar) {
		        
		        }

		        @Override
		        public void onStopTrackingTouch(SeekBar seekBar) {
		        
		        }
			});
	
			String mtmp = SystemProperties.get("persist.dlp.pwmr", "0");
		   	mTextViewR.setText(mtmp);
		   	mSeekBarR.setProgress(Integer.valueOf(mtmp));
			mPwmR = Integer.valueOf(mtmp);
			mtmp = SystemProperties.get("persist.dlp.pwmg", "0");
			mTextViewG.setText(mtmp);
			mSeekBarG.setProgress(Integer.valueOf(mtmp));
			mPwmG = Integer.valueOf(mtmp);
			mtmp = SystemProperties.get("persist.dlp.pwmb", "0");
			mTextViewB.setText(mtmp);
			mSeekBarB.setProgress(Integer.valueOf(mtmp));
			mPwmB = Integer.valueOf(mtmp);

			mtmp   = SystemProperties.get("persist.dlp.pwmr1", "0");
			mPwmR1 = Integer.valueOf(mtmp);
			mtmp   = SystemProperties.get("persist.dlp.pwmg1", "0");
			mPwmG1 = Integer.valueOf(mtmp);
			mtmp   = SystemProperties.get("persist.dlp.pwmb1", "0");
			mPwmB1 = Integer.valueOf(mtmp);

			mtmp   = SystemProperties.get("persist.dlp.pwmr2", "0");
			mPwmR2 = Integer.valueOf(mtmp);
			mtmp   = SystemProperties.get("persist.dlp.pwmg2", "0");
			mPwmG2 = Integer.valueOf(mtmp);
			mtmp   = SystemProperties.get("persist.dlp.pwmb2", "0");
			mPwmB2 = Integer.valueOf(mtmp);

			mtmp   = SystemProperties.get("persist.dlp.brightness", "0");
			mBright = Integer.valueOf(mtmp);
			
			mtmp   = SystemProperties.get("persist.dlp.temp", "0");
			mTempColor = Integer.valueOf(mtmp);			

			if(mTempColor != 0) //hot color
			{
				if ( mBright != 10)//max bright
				{
					SystemProperties.set("persist.dlp.brightness", "10");
				}
				SystemProperties.set("persist.dlp.temp", "0");
				SystemProperties.set("persist.dlp.update", "1");
			}
			else if ( mBright != 10) //max bright
			{
				SystemProperties.set("persist.dlp.brightness", "10");
				SystemProperties.set("persist.dlp.update", "5");
			}
			
			btnWrite = (Button)findViewById(R.id.btnwrite);
			btnWrite.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Toast.makeText(getApplicationContext(),"Write Success",Toast.LENGTH_SHORT).show();
					isWriteSave = true;
				}
			});
			
			btnReset = (Button)findViewById(R.id.btnreset);
			btnReset.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Toast.makeText(getApplicationContext(),"Reset Success",Toast.LENGTH_SHORT).show();
					restorePwm( );
					refreshViews( );
				}
			});

			btnResetGen = (Button)findViewById(R.id.btnresetgen);
			btnResetGen.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Toast.makeText(getApplicationContext(),"Reset Gen Pwm Success",Toast.LENGTH_SHORT).show();
					restoreGenPwm( );
				}
			});


    }

}
